#import "DDZFInfoCell.h"
CGFloat const JTWZFINFOCELLHEIGHT = 44;
@interface DDZFInfoCell()
@property (nonatomic, strong) CCLabel *titleLBL;
@property (nonatomic, strong) CCLabel *contentLBL;
@property (nonatomic, strong) DDButton *btn;
@property (nonatomic, strong) UIView *line;
@property (nonatomic, strong) UIView *rightLine;
@end
@implementation DDZFInfoCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        _index = 10000;
        self.backgroundColor = [UIColor whiteColor];
        [CCNotice addObs:self sel:@selector(dd_cellRotate) name:UIApplicationDidChangeStatusBarOrientationNotification obj:nil];    }
    return self;
}
- (CCLabel *)titleLBL
{
    if (!_titleLBL)
    {
        _titleLBL = [[CCLabel alloc] init];
        _titleLBL.font = FONT(UIFontWeightRegular, 15);
        _titleLBL.textColor = TEXT_GRAY_COLOR;
        [self addSubview:_titleLBL];
        _titleLBL.c_left.c_equal(self).with.coffset(GAP);
        _titleLBL.c_centerY.c_equal(self);
    }
    return _titleLBL;
}
- (CCLabel *)contentLBL
{
    if (!_contentLBL)
    {
        _contentLBL = [[CCLabel alloc] init];
        _contentLBL.font = FONT(UIFontWeightRegular, 15);
        _contentLBL.textColor = TEXT_GRAY_COLOR;
        [self addSubview:_contentLBL];
        _contentLBL.c_right.c_equal(self).with.coffset(-GAP);
        _contentLBL.c_centerY.c_equal(self);
    }
    return _contentLBL;
}
- (DDButton *)btn
{
    if (!_btn)
    {
        _btn = [[DDButton alloc] init];
        _btn.font = FONT(UIFontWeightRegular, 15);
        _btn.autoTitleSize = YES;
        [_btn setValue:[DDHelper help].color forKeyPath:@"_label.textColor"];
        [_btn addTarget:self action:@selector(dd_actionForWuquan) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_btn];
        _btn.c_right.c_equal(self).with.coffset(-GAP);
        _btn.c_centerY.c_equal(self);
    }
    return _btn;
}
- (UIView *)line
{
    if (!_line)
    {
        _line = [[UIView alloc] init];
        _line.backgroundColor = CELL_LINE_COLOR;
        [self addSubview:_line];
        _line.c_left.c_equal(self).with.coffset(0);
        _line.c_right.c_equal(self).with.coffset(0);
        _line.c_bottom.c_equal(self);
        _line.c_height.c_equal(1.0);
    }
    return _line;
}
- (UIView *)rightLine
{
    if (!_rightLine)
    {
        _rightLine = [[UIView alloc] init];
        _rightLine.backgroundColor = CELL_LINE_COLOR;
        [self addSubview:_rightLine];
        _rightLine.c_right.c_equal(self);
        _rightLine.c_bottom.c_equal(self);
        _rightLine.c_top.c_equal(self);
        _rightLine.c_width.c_equal(1.0);
    }
    return _rightLine;
}
- (void)setTitle:(NSString *)title
{
    if (_title != title)
    {
        _title = title;
        self.titleLBL.text = _title;
    }
}
- (void)setContent:(NSString *)content
{
    if (_content != content)
    {
        _content = content;
        if (self.index == 5)
        {
            self.btn.title = _content;
            [_contentLBL removeFromSuperview];
            _contentLBL = nil;
        }else
        {
            self.contentLBL.text = _content;
            [_btn removeFromSuperview];
            _btn = nil;
        }
    }
}
- (void)setIndex:(int)index
{
    if (_index != index)
    {
        _index = index;
        [self dd_cellRotate];
    }
}
- (void)dd_actionForWuquan
{
    if (self.block)
    {
        self.block();
    }
}
- (void)dd_cellRotate
{
    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
    if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
    {
        self.line.hidden = (self.index < 5)?NO:YES;
        self.rightLine.hidden = (self.index % 2)?YES:NO;
    }
    else
    {
        self.line.hidden = (self.index < 6)?NO:YES;
        self.rightLine.hidden = YES;
    }
}
- (void)dealloc
{
    [CCNotice rmObs:self name:UIApplicationDidChangeStatusBarOrientationNotification obj:nil];
}
@end
